package com.jubaopen.service;

import com.jubaopen.bean.FirmInfo;
import com.jubaopen.dao.FirmInfoDAO;

public class FirmInfoService {

	private FirmInfoDAO firmInfoDAO;

	public void setFirmInfoDAO(FirmInfoDAO firmInfoDAO) {
		this.firmInfoDAO = firmInfoDAO;
	}
	
	public boolean save(FirmInfo firmInfo){
		FirmInfo entry = firmInfoDAO.getByUserId(firmInfo.getUserId());
		int ret = 0;
		
		if(entry != null){
			firmInfo.setId(entry.getId());
			ret = firmInfoDAO.update(firmInfo);
		}else {
			ret = firmInfoDAO.add(firmInfo);
		}
		
		return ret>0 ? true:false; 
	}
	
	public FirmInfo queryByUserId(int userId) {
		return firmInfoDAO.getByUserId(userId);
	}
	
}
